<template>
  <div ref="dashboardRef" class="dashboard-container">
    <div class="header">
      <div class="left">
        <span class="full-icon" @click="fullScreen">
          <svg-icon icon-class="full" />
        </span>
      </div>
      <div class="center">数据大屏</div>
      <div class="right">{{ currentTime }}</div>
    </div>
    <div class="content">
      <div class="left">
        <!-- 电商数据 -->
        <div class="shelldata">
          <div class="title">
            电商数据
            <span>Shell Data</span>
          </div>
          <div class="subtitle">
            <div class="label">销售量</div>
            <span class="right">万元</span>
          </div>
          <div class="num">
            <countTo :start-val="startVal" :end-val="endVal" :duration="2000" />
          </div>
        </div>
        <!-- 百分比 -->
        <div class="percentage row">
          <div class="percentage-title">完成百分百</div>
          <div class="progress">
            <ProgressBar :value="progressVal" />
          </div>
        </div>
        <div class="top-search">
          <div class="title">
            热门搜索词
            <span>Top Search</span>
          </div>
          <div class="word-cloud">
            <WordCloud />
          </div>
        </div>
      </div>
      <div class="center">
        <div class="orders">
          <div class="title">订单退单柱状图</div>
          <div class="echarts-bar">
            <OrderEcharts />
          </div>
        </div>
        <div class="bottom-charts-wrapper">
          <div class="item">
            <div class="title">全国订单人数分布图</div>
            <div class="map">
              <MapEcharts />
            </div>
          </div>
          <div class="item">
            <div class="title">购买终端</div>
            <div class="pie">
              <PieEcharts />
            </div>
          </div>
        </div>
      </div>
      <div class="right">
        <div class="statistics-data">
          <div class="title">
            统计数据
            <span> Statistics Data </span>
          </div>
          <Statistics :data="statisticsData" class="statistics" />
        </div>
        <div class="supper-orders">
          <div class="title">
            大额订单Top
            <span> Supper Orders </span>
          </div>
          <div class="table">
            <OrderTable :data="tableData" />
          </div>
        </div>
      </div>
    </div>
    <!-- 动态粒子 -->
    <div class="bg-animate">
      <BgAnimate />
    </div>
  </div>
</template>

<script>
import countTo from "vue-count-to";
import screenfull from "screenfull";

import { parseTime } from "@/utils/index";
import OrderEcharts from "./components/OrderEcharts";
// 字符云组件
import WordCloud from "./components/WordCloud";
// 全国地图
import MapEcharts from "./components/mapEcharts";
// 饼状图
import PieEcharts from "./components/PieEcharts";

// 统计
import Statistics from "./components/Statistics";

// 订单表格
import OrderTable from "./components/OrderTable";

// 动态粒子
import BgAnimate from "./components/BgAnimate.vue";

import ProgressBar from "./components/ProgressBar";

import { statisticsData, tableData } from "./mockData";
export default {
  name: "Dashboard",
  components: {
    countTo,
    WordCloud,
    OrderEcharts,
    MapEcharts,
    PieEcharts,
    Statistics,
    OrderTable,
    BgAnimate,
    ProgressBar,
  },
  data() {
    return {
      currentTime: "",
      startVal: 0,
      endVal: 12010284,
      statisticsData,
      tableData,
      progressVal: 0, // 百分比
    };
  },
  created() {
    this.timer = setInterval(() => {
      this.currentTime = parseTime(new Date());
    }, 1000);

    setTimeout(() => {
      this.progressVal = 88;
    }, 2000);
  },
  methods: {
    fullScreen() {
      if (screenfull.isEnabled) {
        // 控制是否全屏的按钮
        screenfull.toggle(this.$refs.dashboardRef);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.dashboard-container {
  background: #0a1631;
  .title {
    font-family: Microsoft Yahei, Arial, sans-serif;
    font-size: 22px;
    color: #9aa8d4;
    font-weight: 400;
    span {
      font-size: 20px;
      color: #404d69;
      font-weight: 400;
      -webkit-box-pack: center;
      -ms-flex-pack: center;
      justify-content: center;
      text-align: center;
    }
  }
  .header {
    height: 122px;
    box-sizing: border-box;
    position: relative;
    .left {
      position: absolute;
      top: 10px;
      left: 10px;
      .full-icon {
        font-size: 25px;
        color: #9aa8d4;
        cursor: pointer;
      }
    }
    .center {
      background-image: url("../../assets/images/titleBG.png");
      margin: 0 auto;
      background-size: 100% 100%;
      background-position: 50%;
      width: 70%;
      height: 100%;
      text-align: center;
      line-height: 100px;
      font-size: 36px;
      font-family: Microsoft Yahei, Arial, sans-serif;
      font-size: 36px;
      color: #fff;
      text-shadow: #fff 0 0 15px;
      font-weight: 700;
    }
    .right {
      position: absolute;
      right: 30px;
      top: 20px;
      margin-right: 20px;
      font-family: Microsoft Yahei, Arial, sans-serif;
      font-size: 20px;
      color: #fff;
      font-weight: 400;
    }
  }
  .content {
    height: 800px;
    display: flex;
    .left {
      width: 25%;
      padding: 10px 0 0 10px;
      overflow: hidden;
      .row {
        margin: 20px 0;
      }
      .shelldata {
        .subtitle {
          display: flex;
          justify-content: space-between;
          font-family: Microsoft Yahei, Arial, sans-serif;
          font-size: 16px;
          color: #9aa8d4;
          margin-top: 20px;
          .right {
            font-size: 16px;
            color: #73aae5;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            justify-content: center;
            text-align: center;
          }
        }
        .num {
          letter-spacing: 5px;
          font-size: 60px;
          font-weight: 700;
          margin-top: 20px;
          color: #fff;
          text-align: center;
        }
      }
      .percentage {
        &-title {
          font-family: Microsoft Yahei, Arial, sans-serif;
          font-size: 16px;
          color: #9aa8d4;
        }
        .progress {
          width: 85%;
          margin: 40px auto;
        }
      }
      .word-cloud {
        width: 100%;
        height: 390px;
        margin-top: 30px;
        background: #16223c;
      }
    }
    .center {
      width: 50%;
      overflow: hidden;

      .orders {
        .echarts-bar {
          width: 795px;
          height: 360px;
        }
      }

      .bottom-charts-wrapper {
        width: 95%;
        margin: 0 auto;
        display: flex;
        .map,
        .pie {
          width: 397px;
          height: 360px;
        }
      }
    }
    .right {
      width: 25%;
      overflow: hidden;

      .statistics-data {
        .statistics {
          margin-top: 30px;
        }
      }
      .table {
        margin: 20px 10px 0 0;
      }
    }
  }

  .bg-animate {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 15%;
  }
}
</style>
